package com.yanqu.road.server.cmd.specialcookboy.specialcookboysign;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.specialcookboy.SpecialCookBoyProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.specialcookboy.SpecialCookBoySignMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_SPECIAL_COOK_BOY_SIGN_PAST_DAY,desc = "小当家特色服七日签到补签")
public class SpecialCookBoyReSignCmd extends AbstractCommand {

    private int activityId;
    private int day;
    private int conditionId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        SpecialCookBoyProto.SpecialCookBoySevenDaySignAgainReq req = SpecialCookBoyProto.SpecialCookBoySevenDaySignAgainReq.parseFrom(packet.getBytes());
        activityId = req.getActivityId();
        day = req.getDay();
        conditionId = req.getConditionId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = SpecialCookBoySignMgr.signPastDay(player,activityId,conditionId,day);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0){
            SpecialCookBoyProto.SpecialCookBoySevenDaySignAgainResp.Builder builder = SpecialCookBoyProto.SpecialCookBoySevenDaySignAgainResp.newBuilder();
            builder.setRet(ret);
            player.sendPacket(ClientProtocol.U_SPECIAL_COOK_BOY_SIGN_PAST_DAY,builder);
        }
    }
}
